package pac;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class Test2 {
    public static void main(String[] args) {
        Map<String, Integer> hm = new HashMap<>();
        File file = new File("D://a");
        method(hm, file);
        System.out.println(hm);
    }

    private static void method(Map<String, Integer> hm, File file) {
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
            String name = file1.getName();
            String[] split = name.split("\\.");
            String s = split[split.length - 1];
                if (!hm.containsKey(s)) {
                    hm.put(s, 1);
                } else {
                    int integer = hm.get(s);
                    hm.put(s, integer +1);
                }
            }else {
                method(hm,file1);
            }
        }
    }
}